#coding=utf-8
__author__ = 'Meteor'
'''
pymysql:
安装方法：
pip3 install pymysql
'''
import pymysql
import seting

class AcMysql(object):
    def __init__(self):
        self.conn = pymysql.connect(**seting.conn)
        self.curse = self.conn.cursor()

    def exec_sql(self,sql):
        self.curse.execute(sql)

        # 提交sql操作
        info =  self.curse.fetchall()
        self.__commit()

        self.close()
        return info

    def exec_sqls(self,sqls):
        for sql in sqls:
            self.curse.execute(sql)
        self.__commit()
        self.close()

    def __commit(self):
        self.curse.execute('commit;')

    def close(self):
        self.curse.close()
        self.conn.close()






'''
#创建一个连接
conn = pymysql.connect(**seting.conn)

#获取一个游标对象
curse = conn.cursor()

# 执行sql语句
curse.execute('select * from scmuser;')

# 获取查询的结果
print(curse.fetchall())

# 关闭游标
curse.close()
#关闭数据库连接
conn.close()
'''